// 简写  public
class cls{
    constructor(public name:string,public age:number){

    }
    say(){
        console.log(this.name)
    }
}

const A=new cls('zs',26)
A.say()
console.log(A)

interface Inter{
    length:number
}

//泛型约束  限制函数去处理任意带有 .length 属性的所有类型
function fn<T extends Inter>(a:T):T{
   console.log(a.length);
   return a
}
// fn(111)   //报错    Error, number doesn't have a .length property

fn({length:1,a:111})

fn('string')

// fn({id:1})
fn([1])





